<?php include PATH_VIEWS . 'common/header.php'; ?>
<div class="main">
    <?php include PATH_VIEWS . 'common/left.php'; ?>
    <div class="main_right welcome_right" id="slide">
        <dl>
            <dt><h3>操作说明 <span>[关闭/展开]</span></h3></dt>
            <dd class="border">
                <span>以下红色边框的表单是必填项 。</span>
            </dd>
        </dl>
        <dl>
            <dt class="bottom">
            <h4>添加后台菜单</h4>
            </dt>
            <dd>
                <form id="form1" name="form1" method="post" action="<?php echo URL; ?>">
                    <table class="system_envir from_demo"> 
                        <tr>
                            <td>上级菜单名称</td>
                            <td>
                                <select name="FcateIds[]" id="fistVal" onchange="getVal(this.value)">
                                    <option value="0" <?php echo ($cate_id == 0) ? "selected=selected" : ''; ?>>顶级</option>
                                    <?php foreach ($menu_name as $value) { ?>
                                        <option value="<?php echo $value['Fid'] ?>" <?php echo ($cate_id == $value['Fid']) ? "selected=selected" : '' ?> ><?php echo $value['Fname'] ?></option>
                                    <?php } ?>
                                </select>
                                <select id="showMenu" name="FcateIds[]" class="hide">

                                </select>
                            </td>
                            <td></td>
                        </tr>
                        <tr>
                            <td>菜单名称</td>
                            <td class="email"><input type="text" id="menuVal" name="Fname" value="<?php echo $edit['Fname']; ?>" maxlength="16"/></td>
                            <td id="tishi">在填写菜单名称时，请注意简短且要具有概括性。字符长度：2-16个</td>
                        </tr>
                        <tr>
                            <td>class名称</td>
                            <td class="widt"><input type="text" id="fclass" name="Fclass" value="<?php echo $edit['Fclass']; ?>" maxlength="32"/></td>
                            <td id="classTishi">该菜单归属于哪个类文件，请填写类名称（请不要填写page后缀），最多2-32个字符，注：第二级菜单不要填写</td>
                        </tr>
                        <tr>
                            <td>function名称</td>
                            <td class="widt"><input type="text" id="ffunct" name="Ffunction" value="<?php echo $edit['Ffunction']; ?>" maxlength="32"/></td>
                            <td id="functTishi">类中的哪个方法，最多2-32个字符，注：第二级菜单不要填写</td>
                        </tr>
                        <tr>
                            <td>way名称</td>
                            <td><input type="text" id="fway" name="Fway" value="<?php echo $edit['Fway']; ?>" maxlength="16"/></td>
                            <td id="wayTishi">方法中的某一个小功能模块，最多1-16个字符，注：第二级菜单不要填写</td>
                        </tr>
                        <tr>
                            <td>排序</td>
                            <td class="sort"><input type="text" id="sort" name="Fsort" value="<?php echo $edit['Fsort']; ?>" maxlength="2"/></td>
                            <td class="tishi">数值越小，排列越前，数值大小范围：1-99</td>
                        </tr>
                        <tr>
                            <td>是否可见</td>
                            <td>
                                <select name="Fshow" class="show">
                                    <option value="1" <?php echo ($edit['Fshow'] == 1) ? "selected=selected" : ''; ?>>是</option>                           
                                    <option value="0" <?php echo ($edit['Fshow'] == 0) ? "selected=selected" : ''; ?>>否</option>
                                </select>
                            </td>
                            <td>是否可见的意思是，是否在页面顶部或左侧将此菜单显示出来</td>
                        </tr>
                        <tr>
                            <td></td>
                            <td class="subbtn" colspan="2">
                                <input class="ok" type="submit" name="ok" value="确认提交">
                                <a href="<?php echo str_replace('&way=E', '&way=S', URL); ?>'" class="cancel">返回</a>
                            </td>
                        </tr>
                    </table>
                </form>
            </dd>
        </dl>
        <div id="test"></div>
    </div>
</div>
<?php include PATH_VIEWS . 'common/footer.php'; ?>
<script>
    parent_id = $("#fistVal").val();
    two_id =<?php echo $two_id; ?>;
    function lockVal(parent_id, two_id) {
        if (parent_id != 0) {
            $('#showMenu').removeClass('hide');
        } else {
            $('#showMenu').addClass('hide');
        }
//    取数据库菜单
        $.get('index.php?C=System&A=menuLock&pid=' + parent_id + '&sid=' + two_id, function (data) {
            console.log(data);

            $('#showMenu').html(data);
        });
    }
    $("#fistVal").change(function () {
        if ($(this).val() != 0) {
            $('#showMenu').removeClass('hide');
        } else {
            $('#showMenu').addClass('hide');
        }
    });
    lockVal(parent_id, two_id);
</script>
